package org.NooLab.itexx;

import org.NooLab.itexx.app.config.ITexxAppProperties;
import org.NooLab.itexx.app.config.ITexxAppPropertiesIntf;
import org.NooLab.itexx.app.gui.definition.ITexxWindowGui2;
import org.NooLab.itexx.app.up.ITexxWindowStartup;
import org.NooLab.utilities.files.DFutils;
import org.NooLab.utilities.files.PathFinder;

public class AttendingAppProperties {


	private String appBasePath;
	private ITexxAppPropertiesIntf appProperties;

	// ========================================================================
	public AttendingAppProperties() throws Exception{
		
		prepare();
	}
	// ========================================================================

	public ITexxAppPropertiesIntf get() {
		// 
		return appProperties;
	}
	
	private void prepare() throws Exception{
	
		// detecting "first start" after installation
		String binPath = (new PathFinder()).getAppBinPath(this.getClass(), true) ;
		
    	// seedling startup info (such as last session id, last user, whether to load last session...
		ITexxWindowStartup.setApplicationID("noolabwebbrowser", this.getClass());
		
		// read properties from file, if such exists... if not, it creates one with defaults
		appBasePath = ITexxWindowStartup.getProjectBasePath(); 
		System.out.println("application is running on base path : "+appBasePath) ;
		
		appProperties = ITexxAppProperties.getInstance( appBasePath ); 
		
		System.out.println("application is running on configuration : "+appProperties.getConfigFilename()) ;
		
		appProperties.save();
		
		String rawXStartupPropsfilename = DFutils.createPath( binPath ,"");

	}

	public void restoreLastWindowState(ITexxWindowGui2 windowGui) {
		
		
		// check the vertical size: is there enough space to the lower border of the screen
		
		windowGui.controlVerticalSize();

	}
	
	
	
}
